CREATE TABLE [dbo].[TMPLAN_EXTE]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[CO_PLAN_EXTE] [dbo].[TD_VC_003] NOT NULL,
[CO_CNTA_EXTE] [dbo].[TD_VC_020] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NULL CONSTRAINT [DF__TMPLAN_EX__NU_AN__5A846E65] DEFAULT (datepart(year,getdate())),
[CO_CNTA_EMPR] [dbo].[TD_VC_020_CNTA] NULL,
[CO_MONE] [dbo].[TD_VC_003] NULL,
[DE_CNTA_EXTE] [dbo].[TD_VC_100] NOT NULL,
[ST_CNTA_EXTE] [dbo].[TD_VC_001_SINO] NOT NULL CONSTRAINT [DF__TMPLAN_EX__ST_CN__5D60DB10] DEFAULT ('N'),
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TMPLAN_EX__FE_US__5F492382] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TMPLAN_EX__FE_US__603D47BB] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TMPLAN_EXTE] ADD CONSTRAINT [CK__TMPLAN_EX__CO_CN__5C6CB6D7] CHECK (([CO_CNTA_EMPR]>='0' AND [CO_CNTA_EMPR]<='99999999999999999999'))
GO
ALTER TABLE [dbo].[TMPLAN_EXTE] ADD CONSTRAINT [CK__TMPLAN_EX__NU_AN__5B78929E] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TMPLAN_EXTE] ADD CONSTRAINT [CK__TMPLAN_EX__ST_CN__5E54FF49] CHECK (([ST_CNTA_EXTE]='N' OR [ST_CNTA_EXTE]='S'))
GO
ALTER TABLE [dbo].[TMPLAN_EXTE] ADD CONSTRAINT [XPKTMPLAN_EXTE] PRIMARY KEY CLUSTERED  ([CO_EMPR], [CO_PLAN_EXTE], [CO_CNTA_EXTE]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TMPLAN_EXTE] ADD CONSTRAINT [FK1_TMPLAN_ANNO_A_TMPLAN_EXTE] FOREIGN KEY ([CO_EMPR], [CO_CNTA_EMPR]) REFERENCES [dbo].[TMPLAN_ANNO] ([CO_EMPR], [CO_CNTA_EMPR])
GO
ALTER TABLE [dbo].[TMPLAN_EXTE] ADD CONSTRAINT [PK1_TMPARA_EXTE_A_TMPLAN_EXTE] FOREIGN KEY ([CO_EMPR], [CO_PLAN_EXTE]) REFERENCES [dbo].[TMPARA_EXTE] ([CO_EMPR], [CO_PLAN_EXTE])
GO
